package com.zqxq.lottery.entity.o2o.user;

import com.zqxq.common.utils.DispatcherUtils;
import com.zqxq.lottery.entity.po.user.UserMsgPO;
import com.zqxq.lottery.entity.vo.user.UserMsgVO;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description ：
 * @Author ： 解风
 * @Date ： 2018/03/14 16:16
 */
public class UserMsgO2O {

    public static UserMsgVO toVO(UserMsgPO po) {
        if (po == null) {
            return null;
        }
        UserMsgVO userMsgVO = new UserMsgVO();
        userMsgVO.setId(DispatcherUtils.parseString(po.getId()));
        userMsgVO.setUserId(DispatcherUtils.parseString(po.getUser_id()));
        userMsgVO.setContent(po.getContent());
        userMsgVO.setStatus(DispatcherUtils.parseString(po.getStatus()));
        userMsgVO.setCreateTime(DispatcherUtils.parseDateTimeStr(po.getCreate_time()));
        return userMsgVO;
    }

    public static UserMsgPO toPO(UserMsgVO vo) {
        if (vo == null) {
            return null;
        }
        UserMsgPO userMsgPO = new UserMsgPO();
        userMsgPO.setId(DispatcherUtils.parseLong(vo.getId()));
        userMsgPO.setUser_id(DispatcherUtils.parseLong(vo.getUserId()));
        userMsgPO.setContent(vo.getContent());
        userMsgPO.setStatus(DispatcherUtils.parseInteger(vo.getStatus()));
        userMsgPO.setCreate_time(DispatcherUtils.parseDateTime(vo.getCreateTime()));
        return userMsgPO;
    }

    public static List<UserMsgVO> toVOList(List<UserMsgPO> list){
        List<UserMsgVO> result = new ArrayList<>();
        if(list != null && list.size() > 0){
            for (UserMsgPO po : list) {
                result.add(toVO(po));
            }
        }
        return result;
    }


}
